# class Restaurant(object):
#     menu = {
#         '土豆丝': 8,
#         '剁椒鱼头': 78,
#         '胡辣汤': 3,
#         '羊汤': 8,
#         '小葱拌豆腐': 15,
#         '鱼香肉丝': 21,
#         '辣子鸡丁': 43,
#         '拍黄瓜': 5,
#     }
#
#     def __init__(self, num):
#         self.num = num
#         self.my_menu = {}
#         print(f'{num}位爷，里边请~~~')
#
#     def __exit__(self, exc_type, exc_val, exc_tb):
#         print(f"总共消费{self.price + sum(self.my_menu.values())}")
#
#     def __enter__(self):
#         self.price = self.num * 2
#
#     def __add__(self, other):
#         if other in self.my_menu:
#             self.my_menu[other] += self.menu[other]
#         else:
#             self.my_menu[other] = self.menu[other]
#
#
# r = Restaurant(4)
# with r as f:
#     r + '小葱拌豆腐'
#     r + '辣子鸡丁'
# print('下次再来啊！')


def hanoi(n, x, y, z,num=0):
    if n == 1:
        print(x, '-->', z)
        num += 1
    else:
        num += hanoi(n - 1, x, z, y)
        print(x, '-->', z)
        num +=1
        num += hanoi(n - 1, y, x, z)
    return num


n = int(input('请输入数量：'))
print(hanoi(n, 'A', 'B', 'C'))
